#ifndef WORK_H
#define WORK_H
#include <QObject>
#include "Ptr.hpp"
#include "Document.h"
#include "SelectRegion.h"
#include "CanvasViewport.h"
#include "ViewportControl.h"



using namespace OOPUtils;



class Work : public QObject
{

  Q_OBJECT

private:

  Ptr< Document > _pDoc;
  Ptr< SelectRegion > _pSelectRegion;
  Ptr< ViewportControl > _pViewportCtrl;
  CanvasViewport * _pViewportUI;
  bool _isQuickMaskMode;
  vector< Ptr< AbstractAction > > _actionRecordList;
  int _nextActionIndex;
  bool _hasSaved;

  void _replay ();

  void _clear ();

public:

  Work (Ptr< Document > pDoc, Ptr< ViewportControl > pViewportCtrl);
  Work (Ptr< AbstractAction > pInitAction, Ptr< ViewportControl > pViewportCtrl);
  ~Work ();

  void save (const QString & filepath);
  void placeImage (const QString & filepath);
  Ptr< Document > getDoc ();
  Ptr< ViewportControl > getViewportCtrl ();
  CanvasViewport * getViewportUI ();
  void setSelectRegion (Ptr< SelectRegion > pSelectRegion);
  Ptr< SelectRegion > getSelectRegion ();
  void setQuickMaskMode (bool isQuickMaskMode);
  bool isQuickMaskMode () const;

  void addActionRecord (Ptr< AbstractAction > pAction);
  void undo ();
  void redo ();
  bool canUndo () const;
  bool canRedo () const;
  int getNextActionIndex () const;
  void playAction (Ptr< AbstractAction > pAction);

public slots:
  
  void handleCanvasPainting (QPainter & painter);

signals:

  void workUpdated ();

};

#endif // WORK_H
